package com.sportschain.app.circle;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.sportschain.app.R;
import com.sportschain.app.circle.activity.PublishMomentActivity;
import com.sportschain.app.core.adapter.TabPagerAdapter;
import com.sportschain.app.core.base.BasePagerFragment;

import butterknife.BindView;

public class CircleFragment extends BasePagerFragment {

    @BindView(R.id.tab_layout)
    TabLayout mTabLayout;
    @BindView(R.id.container_vp)
    ViewPager mContainerVp;
    @BindView(R.id.publish_btn)
    FloatingActionButton mPublishBtn;

    private TabPagerAdapter mPagerAdapter;

    public static CircleFragment newInstance() {

        Bundle args = new Bundle();

        CircleFragment fragment = new CircleFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_circle;
    }

    @Override
    protected void initView(View view, Bundle savedInstanceState) {
        mContainerVp.setOffscreenPageLimit(3);
        mPagerAdapter = new TabPagerAdapter(getChildFragmentManager());
        mPagerAdapter.addFragment(CircleListFragment.newInstance(), "跑步");
        mPagerAdapter.addFragment(CircleListFragment.newInstance(), "健身");
        mPagerAdapter.addFragment(CircleListFragment.newInstance(), "饮食");
        mPagerAdapter.addFragment(CircleListFragment.newInstance(), "交易");
        mContainerVp.setAdapter(mPagerAdapter);

        mTabLayout.setupWithViewPager(mContainerVp);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {
        mPublishBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(PublishMomentActivity.class);
            }
        });
    }
}
